<?php
namespace Admin\Controller;
use Admin\Controller\AdminController;
use Admin\Model\FeeModel;
class FeeController extends AdminController
{
    //查新党费缴纳总记录$this->checkPower();
    public function totalFee ()
    {
        $this->checkPower();
        $name = "";
        if(!empty($_GET['name'])){
            $name = I("get.name");
        }
        $year = "";
        if(!empty($_GET['year'])){
            $year = I("get.year");
        }
        $data['name'] = $name;
        $data['year'] = $year;

        //排序字段
        $order = "";
        if(!empty($_GET['order'])){
            $order = I("get.order");
        }
        //排序方式
        $order1 = "";
        if(!empty($_GET['order1'])){
            $order1 = I("get.order1");
        }
        $data['order'] = $order;
        $data['order1'] = $order1;

//        var_dump($data);die;
        $this->title = "党费缴纳总记录";
        $fee = new FeeModel();
        $res = $fee -> queryAllFee($data);
        $show = $res['show'];
        $list = $res['list'];
        $this->feeList = $list;
        $this->page = $show;
        //总金额
        $totalFee = $fee -> queryTotalFee($data);
        $this->totalFee = $totalFee['total'];
        $this->display("Fee/totalFeeList");
    }

    public function edit()
    {
        $this->checkPower();
        $fee = new FeeModel();
        if(IS_GET){
            $id = I("get.id");//党费缴纳记录表id;
            //通过id查询缴纳金额
            $res = $fee -> queryMoneyById($id);
            $this -> assign("feeInfo",$res['0']);
            $this -> display("Fee/edit");
        }
        if(IS_POST){
            $data = I("post.");

            $res = $fee -> editFee($data);
            if($res > 0){
                echo "<script>parent.location.reload();</script>";
            }else{
                $this -> error("编辑失败");
            }

        }

    }
}